import tool from '../tool'
import util from '_util/index'
const store = util.store
import _ from 'lodash'
import in_array from 'in_array'
import logic from '_logic'

export default{
  forSpecialType(_this, mid, param){
    if (mid == 42) {
      let op=util.getOp(_this);
      let specialType =null;
      if(op=='insert') {
        specialType = util.store.get(_this, 'type', 'product')
        if(!specialType) {
          util.showMsg(_this, 'success', '新增商品时请先选择商品类型!',null,()=>{
            util.jump(_this,'/page/list?ctl=Hproduct&title=商品管理');
          });
        }
      }else{
        specialType = util.store.get(_this, 'editVo.type');
      }
      param.specialType = specialType
    }
  },
  showSpecialTypeName(_this){
    let typeName = util.store.get(_this, 'typeName', 'product')
    _this.val = typeName
  },
  setType(_this){
    let type = util.store.get(_this, 'type', 'product')
    util.store.push(_this, 'setEditVo', 'editVo', 'type', type,'')
  },
  beforeAdd(_this,clb){
    logic.edit.showEditPop(_this, 40, ()=> {
      let product_type = util.store.get(_this, 'editVoModal.product_type')
      logic.edit.getSpecialTypeName(_this, product_type, (typeName)=> {
        util.store.push(_this, 'setType', 'type', false, product_type, 'product');

        util.store.push(_this, 'setTypeName', 'typeName', false, typeName, 'product')
        clb()

      })
    });
  },
  toHide(_this){
    let conf = {'跟团游' : [118],'半/一日游' : [111,112,113],'门票' : [111,112,113], '土特产' : [111,112,113]};
    // let typeName = util.store.get(_this, 'typeName', 'product');
    let typeName = util.store.get(_this, 'editVo.type_name');
    tool.cl('typeName:',typeName);
    let arr = conf[typeName];
    tool.cl('arr:',arr);
    _this.hide_field_ids = arr;

  },
}
